package cn.itrip.trade.config;

import cn.itrip.beans.dtos.ResultCodeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @Author:小伟
 * @Description:
 * @Date:2020-02-28 16:14
 **/
@Data
@EqualsAndHashCode(callSuper = true)
public class StateException extends RuntimeException{
    @ApiModelProperty(value = "状态码")
    private String errorCode;

    private String success;

    /**
     * 接收状态码和信息
     * @param errorCode
     * @param msg
     */
    public StateException(String errorCode,String msg,String success){
        super(msg);
        this.errorCode=errorCode;
        this.success = success;
    }

    /**
     * 接收枚举类型
     * @param resultCodeEnum
     */
    public StateException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMsg());
        this.errorCode=resultCodeEnum.getErrorCode();
    }
    @Override
    public String toString() {
        return "KetaiException{" +
                "msg=" + this.getMessage() +
                ", errorCode=" + errorCode +
                '}';
    }
}
